﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace JTG.CheckInMachine
{
    public partial class Keyboard : System.Windows.Forms.UserControl
    {
        public EventHandler NumberEvent; //数字按键事件
        public EventHandler DeleteEvent; //删除
        public EventHandler CleanEvent;  //清除
        public EventHandler OkEvent;     //确认事件

        public Keyboard()
        {
            InitializeComponent();
        }

        private void btn_MouseUp(object sender, MouseEventArgs e)
        {
            ((Button) sender).FlatAppearance.BorderSize = 0;
        }

        private void btn_MouseDown(object sender, MouseEventArgs e)
        {
            ((Button)sender).FlatAppearance.BorderSize = 1;
        }

        private void btn_Click(object sender, EventArgs e)
        {
            if (NumberEvent == null) return;

            var number = ((Button) sender).Name.Substring(((Button) sender).Name.Length - 1, 1);
            
            if (number.Equals("d")) number = ".";

            NumberEvent(number, e);
        }

        private void btnOk_Click(object sender, EventArgs e)
        {
            OkEvent?.Invoke(sender, e);
        }

        private void btnClean_Click(object sender, EventArgs e)
        {
            CleanEvent?.Invoke(sender, e);
        }

        private void btnDelete_Click(object sender, EventArgs e)
        {
            DeleteEvent?.Invoke(sender, e);
        }
    }
}